import logging 

from constants import Constants

class BaseChecker(object):
    def __init__(self,db_service):
        self.db_service=db_service
        self.logger=logging.getLogger("BaseChecker")

    def load_bat_batch_status_max_data(self,db_session,batch_type,timezone_id=None):
        """
        获取最大日期
        :param db_session:
        :param batch_type:
        :param timezone_id:
        :return:
        """
        if timezone_id is None:
            sql="SELECT MAX(T.BATCH_DATE) MAX_DATE FROM GMRMBATCH.BAT_BATCH_STATUS T WHERE T.BATCH='{}'".format(batch_type)
        else:
            sql="SELECT MAX(T.BATCH_DATE) MAX_DATE FROM GMRMBATCH.BAT_BATCH_STATUS T WHERE T.TIMEZONE='{}' AND T.BATCH='{}'".format(timezone_id,batch_type)
        df_max_date=db_session.get_dataframe_by_sql(sql)
        return df_max_date.loc[0,"MAX_DATE"]